/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-06-22 20:03:04
 * @LastEditTime: 2024-12-06 22:26:54
 * @FilePath: /internet_things/src/utils/table.ts
 */
//间隔行 样式
export const getRowClassName = (_record: any, index: number) => {
    if (index % 2 != 0) {
        return `table_stripe`;
    } else {
        return '';
    }
};

/**
 * 获取第一个表格的可视化高度
 * @param {*} extraHeight 额外的高度(表格底部的内容高度 Number类型,默认为74) 
 * @param {*} id 当前页面中有多个table时需要制定table的id
 */
export const getTableScroll = (extraHeight?: any, id?: any) => {
    if (!extraHeight || typeof extraHeight == "undefined") {
        //  默认底部分页 70 + 边距10
        extraHeight = 80
    }
    let tHeader = null
    if (id) {
        tHeader = document.getElementById(id) ? document.getElementById(id)?.getElementsByClassName("ant-table-thead")[0] : null
    } else {
        tHeader = document.getElementsByClassName("ant-table-thead")[0]
    }
    //表格内容距离顶部的距离
    let tHeaderBottom = 0
    if (tHeader) {
        tHeaderBottom = tHeader.getBoundingClientRect?.().bottom
    }
    //窗体高度-表格内容顶部的高度-表格内容底部的高度
    let height = document.body.clientHeight - tHeaderBottom - extraHeight;
    // let height = `calc(100vh - ${tHeaderBottom + extraHeight}px)`
    return height
}